﻿@model List<Entity.Report>
@{
    ViewBag.Title = "List Report";
    var date=ViewBag.Date;
}
@section breadcrumb
{
    <li>@Html.ActionLink("Report", "Index", "Report")</li>
}
<div class="box box-primary">
    <div class="box-header">
        <h3 class="box-title">Search</h3>
    </div>
    @using (Html.BeginForm())
    {
        <div class="box-body">
            <div class="form-group">
                <div class="col-md-4">
                   <div class="input-group">
                        <div class="input-group-addon">
                            <i class="fa fa-calendar"></i>
                        </div>
                        @Html.TextBox("date" ,((DateTime)ViewBag.Date).ToString("MM/dd/yyyy"), new { @class  = "form-control"})
                    </div>
                </div>
                </div>
            <div class="clear"></div>
        </div>
        <div class="box-footer">
            <button type="submit" class="btn btn-primary pull-right">Search</button>
            <div class="clear"></div>
        </div>
        <div class="clear"></div>
    }
</div>
<div class="row">
    <div class="col-xs-12">
        <div class="box">
            <div class="box-header">
                <h3 class="box-title">List of Reports</h3>
            </div>
                
            <!-- /.box-header -->
            <div class="box-body table-responsive">
                <table id="example2" class="table table-bordered table-hover">
                    <thead>
                        <tr>
                            <th>
                                Requirement
                            </th>
                            <th>
                                Report Result
                            </th>
                            <th>
                                Next Task
                            </th>
                            <th>
                                % Completed
                            </th>
                            <th>
                                Report Type
                            </th>
                            <th>
                                Files attachment
                            </th>
                            <th>
                                Comment
                            </th>
                            <th>
                                Action
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var item in Model)
                        {
                            <tr>
                                <td>
                                    @item.AssignTask.Requirement
                                </td>
                                <td>
                                    @item.ReportResult
                                </td>
                                <td>
                                    @item.NextTask
                                </td>
                                <td>
                                    @item.CompletedPercent
                                </td>
                                @if (item.ReportType == 1)
                                { 
                                    <td>
                                        Day
                                    </td>
                                }
                                else
                                {
                                    <td>
                                        Month
                                    </td>
                                }
                                <td>
                                    @if (item.Documents != null && item.Documents.Count > 0)
                                    {
                                        <ul>
                                            @for (int i = 0; i < item.Documents.Count; i++)
                                            {
                                                <li>@Html.ActionLink(item.Documents[i].Name, "DownloadFile","Upload" , new {id = item.Documents[i].Id}, null)</li>
                                            }
                                        </ul>
                                    }
                                </td>
                                <td>
                                    @item.Comment
                                </td>
                                <td>
                                    <a class="btn btn-default btn-flat" href="@Url.Action("Edit", new { id = item.Id })"><i class="fa fa-edit"></i></a>
                                    <a class="btn btn-default btn-flat" href="@Url.Action("Delete", new { id = item.Id })"><i class="fa fa-remove"></i></a>
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>
            </div>
            <!-- /.box-body -->
        </div>
        <!-- /.box -->
    </div>
</div>


@section Script
{
    <script type="text/javascript">
        $(function () {
            $('#example2').dataTable({
                "bPaginate": true,
                "bLengthChange": false,
                "bFilter": false,
                "bSort": false,
                "bInfo": true,
                "bAutoWidth": false,
                "aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "Tất cả"]],
                "iDisplayLength": 25,
            });
        });
</script>    
}